﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Industry.Framework.Common;
//using LitJson;
using Onlyle.Model;
using System.Text.RegularExpressions;

namespace Onlyle.Business
{
    public class PingTaiLogin
    {
        //static string GetAccess_token(string code)
        //{
        //    string apikey = "4UkeEoyGYKvANXNQqiLqs0Om";
        //    string SecretKey = "VUCoF1ojNwTiaLVggt1EHXcqxjuFspyE";
        //    string redirect_uri = "http://www.onlyle.com:8888/account/login";
        //    string url = "https://openapi.baidu.com/social/oauth/2.0/token";
        //    string postData = "grant_type=authorization_code&" + string.Join("&", "code=" + code, "client_id=" + apikey, "client_secret=" + SecretKey, "redirect_uri=" + redirect_uri);
        //    WebClient webclient = new WebClient();
        //    string jsonData = webclient.Post(url, postData);
        //    JsonData objData = JsonMapper.ToObject(jsonData);
        //    string access_Token = (objData["access_token"] ?? "").ToString();
        //    return access_Token;
        //}

        //public static E_User GetUserInfo(string code)
        //{
        //    //E_User e_user = new E_User();
        //    //string access_Token = GetAccess_token(code);
        //    //WebClient webclient = new WebClient();
        //    //string userstr = webclient.GetHtml("https://openapi.baidu.com/social/api/2.0/user/info?access_token=" + access_Token);
        //    //JsonData objdata = JsonMapper.ToObject(userstr);
        //    //DateTime Birthday;
        //    //DateTime.TryParse(objdata["birthday"].ToString(), out Birthday);
        //    //e_user.User_Birthday = Birthday;
        //    //e_user.User_city = Regex.Unescape((objdata["city"] ?? "").ToString());
        //    //e_user.User_Headurl = (objdata["headurl"] ?? "").ToString();
        //    //e_user.User_Hometown = Regex.Unescape((objdata["hometown_location"] ?? "").ToString());
        //    //e_user.User_hs_history = Regex.Unescape((objdata["hs_history"] ?? "").ToString());
        //    //e_user.User_ID = (objdata["social_uid"] ?? "").ToString();
        //    //e_user.User_is_verified = 0;
        //    //e_user.User_Mainurl = (objdata["mainurl"] ?? "").ToString();
        //    //e_user.User_Meida_Type = (objdata["media_type"] ?? "").ToString();
        //    //e_user.User_Meida_Uid = (objdata["media_uid"] ?? "").ToString();
        //    //e_user.User_Name = Regex.Unescape((objdata["username"] ?? "").ToString());
        //    //e_user.User_province = Regex.Unescape((objdata["province"] ?? "").ToString());
        //    //e_user.User_Sex = (objdata["sex"] ?? "").ToString();
        //    //e_user.User_Tinyurl = (objdata["tinyurl"] ?? "").ToString();
        //    //e_user.User_university_history = Regex.Unescape((objdata["university_history"] ?? "").ToString());
        //    //e_user.User_work_history = Regex.Unescape((objdata["work_history"] ?? "").ToString());
        //    //return e_user;
        //}
    }
}
